<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:LJQ <liujiqi@etrol.com>
// +-----------------------------------------------------------------------

namespace app\rehearse\model;

use app\common\model\Base;
use app\basic\model\Unit;
/**
 * 脚本管理
 */
class Plan extends Base{
  protected $name = 'reserveplan';
  protected $createTime = 'createTime';
  protected $updateTime = 'updateTime';
  
  public $planTypeList=[] ;

  public  function getType(){

   $planType=db('basicinfo')->where(array('sysCode'=>20))->column('subsystemName','subsystemNo');
   $this->planTypeList=$planType;
   return $this->planTypeList;
  }

  public function gettypeIdAttr($value,$data){
    $this->getType();
    if($data['typeId']){
      return $this->planTypeList[$data['typeId']];
    }
    return null;
  }

  public function unit(){

    return $this->hasOne(Unit::class,'id','unitId');

  }
  
  public function scripts(){
  	return $this->hasMany('Script','reservePlanId','id');
  }

}